#include<iostream>
using namespace std;
int main(){
	int n,m,t,arr2[101][101]={0},arr1[101][101] = {0};
	cin >> m >> n;
	for(int i = 0; i < m; i++){
		for(int j = 0; j < n; j++){
			cin >> arr1[i][j];
			arr2[i][j] = arr1[i][j];
		}
	}
	for(int i = 0; i < m; i++){
		for(int j = 0; j < n; j++){
			if(i >= 1 && i < m - 1 && j >=1 && j < n - 1)
			arr2[i][j] = (int)((arr1[i][j]+arr1[i][j-1]+arr1[i][j+1]+arr1[i-1][j]+arr1[i+1][j]) / 5.0 + 0.5);
			cout << arr2[i][j] << ' ';
	}
		cout << endl;
	}
	return 0;
} 
